const Tesseract = require('tesseract.js');
const path = require('path');
const { PNG } = require('pngjs');
const fs = require("fs");
const imagePath = path.join(__dirname, 'img/page-kdj.png');
const t1Buffer = fs.readFileSync(imagePath);

Tesseract.recognize(
    t1Buffer,
    'eng',
    {
        logger: m => console.log(m) // 可选：查看识别进度
    }
).then(({ data: { text } }) => {
    console.log('识别结果:', text.trim());
}).catch(err => {
    console.error('识别失败:', err);
});